import * as data from './data';
import * as util from '../../../util';
import log from '../../../log';

function getQueTempQuestions(queTempId) {
    log.debug(`获取问卷${queTempId}问题`);
    return data.getQueTempQuestions(queTempId);
}
function add(question, options) {
    log.info(`添加问题[${question.title}]`);
    question.id = util.uuid();
    if (options !== null) {
        options.forEach(opt => {
            opt.questionId = question.id;
            opt.id = util.uuid();
        });
    }
    const qId = {id: question.id};
    return data.add(question, options).then(() => qId);
}
function edit(id, question, options) {
    if (options !== null) {
        options.forEach(opt => {
            opt.questionId = id;
            opt.id = util.uuid();
        });
    }
    return data.edit(id, question, options).then(() => {});
}
function del(id) {
    log.info(`删除问题[${id}]`);
    return data.del(id).then(() => {});
}
export {getQueTempQuestions, add, edit, del};
